/*
 * @Description: 请求
 * @Version: 1.0
 * @Autor: JiaJun Wu
 * @Date: 2021-09-14 15:34:29
 * @LastEditors: JiaJun Wu
 * @LastEditTime: 2021-09-18 15:28:08
 */
use rocket::serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug)]
#[serde(crate = "rocket::serde")]
pub struct Params<T> {
    // 请求条件
    pub body: Option<T>,
    // 第几页
    pub page: Option<i64>,
    // 一页限制条数
    pub limit: Option<i64>,
    // 根据字段排序
    #[serde(rename = "sortName")]
    pub sort_name: Option<String>,
    // 排序规律
    #[serde(rename = "sortOrder")]
    pub sort_order: Option<String>,
}

impl Default for Params<Login> {
    fn default() -> Self {
        Self {
            body: None,
            page: Some(1),
            limit: Some(10),
            sort_name: None,
            sort_order: None,
        }
    }
}

/// 登陆结构体
#[derive(Debug, Deserialize, Serialize)]
#[serde(crate = "rocket::serde")]
pub struct Login {
    pub username: String,
    pub password: String,
}

/// 删除参数结构体
#[derive(Debug)]
pub struct RemoveList {
    pub ids: String,
}

/// 用户登陆响应信息
#[derive(Deserialize, Serialize, Debug, Default)]
#[serde(crate = "rocket::serde")]
pub struct ResUserInfo {
    #[serde(rename = "userInfo")]
    pub user_info: Option<bson::ordered::OrderedDocument>,
    pub token: Option<String>,
}
